package com.exception.solve;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

//测试运行时异常和处理方式（RuntimeException）
public class Test01 {
    public static void main(String[] args) {
        int b = 0;
        if (b!=0)
            System.out.println(1/b);

        String str = null;
        if (str!=null)
            System.out.println(str.charAt(0));

        Animal a = new Cat();
        if (a instanceof Dog) {
            Dog d = (Dog) a;
        }

        int[] arr = new int[5];
        int index = 5;
        if (index>=0&&index<5)
            System.out.println(arr[5]);

        String str2 = "1234abcf";

        Pattern p = Pattern.compile("^\\d+$");
        Matcher m = p.matcher(str2);
        if (m.matches()){
            System.out.println(Integer.parseInt(str2));
        }
    }
}
class Animal{

}
class Dog extends Animal{

}
class Cat extends Animal{

}
